from django import template
register = template.Library()
from recaptcha_django_gae_client import API_SSL_SERVER, API_SERVER, VERIFY_SERVER
from django.conf import settings

@register.inclusion_tag('recaptcha_django_gae_client/recaptcha.html')
def recaptcha():
    """Gets the HTML to display for reCAPTCHA

    Uses settings"
    RECAPTCHA_PUBLIC_KEY -- The public api key -- required
    RECAPTCHA_USE_SSL -- Should the request be sent over ssl?
    RECAPTCHA_ERROR -- An error message to display (from RecaptchaResponse.error_code)"""
    public_key = settings.RECAPTCHA_PUBLIC_KEY
    use_ssl = getattr(settings, 'RECAPTCHA_USE_SSL', False)
    error = getattr(settings, 'RECAPTCHA_ERROR', False)

    error_param = ''
    if error:
	error_param = '&error=%s' % error
    if use_ssl:
        server = API_SSL_SERVER
    else:
        server = API_SERVER    
    return {
        'ApiServer' : server,
        'PublicKey' : public_key,
        'ErrorParam' : error_param,
        }
